package Hash;

import java.util.*;
import java.util.HashMap;
import java.util.List;

/**
 * Created with Intellij IDEA.
 * Description;
 * User:TQ02
 * Data:2024-03-01
 * Time:14:57
 * Text：49. 字母异位词分组
 */
public class Text2 {
    public List<List<String>> groupAnagrams(String[] strs) {
        HashMap<String,List<String>> map=new HashMap<>();
        for(String str:strs){
            char[] tmp=str.toCharArray();
            Arrays.sort(tmp);
            String key=new String(tmp);
            if(!map.containsKey(key)){
                List t1=new ArrayList();
                map.put(key,t1);
            }
            map.get(key).add(str);
        }
        return new ArrayList(map.values());

    }
}
